home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue15 / source / example-1b.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-14  |  1.1 KB  |  44 lines

  1. /*
  2.  * Example 1b.c - Sample source from The RenderMan Companion
  3.  * by Steve Upstill
  4.  *
  5.  */
  6. #include <ri.h>
  7. #define NFRAMES    10    /* number of frames in the animation */
  8. #define NCUBES     5     /* # of minicubes on a side of the color cube */
  9. #define FRAMEROT   5.0   /* # of degress to rotate cube between frames */
  10.  
  11. main()
  12. {
  13.    int frame;
  14.    float scale;
  15.    char   filename[20];
  16.  
  17.    RiBegin(RI_NULL);      /* Start the renderer */
  18.  
  19.       RiLightSource("distantlight", RI_NULL);
  20.  
  21.       /* Viewing transformation */
  22.       RiProjection("perspective", RI_NULL);
  23.       RiTranslate(0.0, 0.0, 1.5);
  24.       RiRotate(40.0, -1.0, 1.0, 0.0);
  25.  
  26.       for (frame = 1; frame <= NFRAMES; frame++)
  27.       {
  28.             sprintf(filename, "anim%d.pic", frame);
  29.          RiFrameBegin(frame);
  30.             RiDisplay(filename, RI_FILE, RI_RGBA, RI_NULL);
  31.             RiWorldBegin();
  32.                scale=(float)(NFRAMES-(frame-1))/(float)NFRAMES;
  33.                RiRotate(FRAMEROT * frame, 0.0, 0.0, 1.0);
  34.                RiSurface("matte", RI_NULL);
  35.  
  36.                /* Define the cube */
  37.                ColorCube(NCUBES,scale);
  38.             RiWorldEnd();
  39.          RiFrameEnd();
  40.       }
  41.    RiEnd();
  42. }
  43.  
  44.